//
//  HKDataSource.h
//  YNDemo
//
//  Created by 胡锦涛 on 2020/11/13.
/*
 列表快读搭建及部分代码抽取、解耦
 1.UITableView使用
 @property (nonatomic, strong) UITableView * tableView ;
 @property (nonatomic, strong) HKDataSource * dataSource ;
 self.dataSource = [[HKDataSource alloc] initWithIdentifier:reuseId configureBlock:^(YNTableViewCell *cell, YNUser *model, NSIndexPath *indexPath) {
     //cell赋值
     cell.model = model;
 }];
 self.tableView = [HKDataSource setupTableView];
 [self.view addSubview:self.tableView];
 [_tableView registerClass:[YNTableViewCell class] forCellReuseIdentifier:reuseId];
 self.tableView.dataSource = self.dataSource;
 self.tableView.delegate = self;
 
 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
     [self.view yn_showErrorWithText:[NSString stringWithFormat:@"您点击了第%ld个",indexPath.row]];
 }
 
 2.UICollectionView
 
 */

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
typedef void(^YNCellConfigure)(id _Nullable cell , id _Nullable model, NSIndexPath * _Nullable indexPath);
NS_ASSUME_NONNULL_BEGIN

@interface HKDataSource : NSObject<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong) NSMutableArray * dataArray ;

//自定义初始化方法
- (id)initWithIdentifier:(NSString *)identifier configureBlock:(YNCellConfigure)configure;

//CellIdentifier
@property (nonatomic, strong) IBInspectable NSString * cellIdentifier ;

//cellConfigure
@property (nonatomic, copy) YNCellConfigure cellConfigure ;

- (void)addDataArray:(NSArray*)array;

- (id)modelsAtIndexPath:(NSIndexPath*)indexPath;

#pragma mark -- 列表快速创建 --
+(UITableView *)setupTableView;
@end

NS_ASSUME_NONNULL_END
